﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Cash.Model;
using CashCommon;
using CashResource;
using System.IO;
using System.Drawing.Printing;
using System.Drawing;

namespace Cash
{
    public static class Prints
    {
        #region Печать/просмотр копии чека
        
        public static void PrintCashCopy(CashRegister cashRegister)
        {
            _cashRegister = cashRegister;
            PrepareCashCopyForPrint();
            _formMain.printDoc.Print();
        }

        public static void PreviewCashCopy(CashRegister cashRegister)
        {
            _cashRegister = cashRegister;
            PrepareCashCopyForPrint();
            _formMain.printPreviewDialog.ShowDialog();
        }

        #endregion

        private static void PrepareCashCopyForPrint()
        {
            _formMain.printDoc.DocumentName = CommonText.PrintDocCashCopyTitle;
            _formMain.printDoc.PrintPage += new PrintPageEventHandler(DrawCashCopy);
            _formMain.pageSetupDialog.PageSettings.Landscape = true;
        }

        private static void DrawCashCopy(object sender, PrintPageEventArgs e)
        {
            StringFormat centerLeft = new StringFormat() { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Near };
            float topMargin = e.MarginBounds.Top;
            float leftMaring = e.MarginBounds.Left + 100;

            e.Graphics.DrawString("ОАО Енисейская ТГК(ТГК-13)", new Font(FontFamily.GenericSansSerif,  8), Brushes.Black, leftMaring, topMargin, centerLeft);
        }

        private static CashRegister _cashRegister;
        private static FormMain _formMain = Tools.MainForm as FormMain;
    }
}
